import App from './App'

import Vue from 'vue'
import Vuex from 'vuex'
import store from '@/store/index.js'
Vue.config.productionTip = false
App.mpType = 'app'

import uView from 'uview'
Vue.use(uView);
import navbar from '@/components/navbar.vue'
Vue.component('navbar',navbar)


// 引入语言包，注意路径
import zh from '@/common/locales/zh.js';
import en from '@/common/locales/en.js';
import th from '@/common/locales/th.js';

// 引入并使用vue-i18n
import VueI18n from 'vue-i18n'
Vue.use(VueI18n)

// 构造i18n对象
const i18n = new VueI18n({
	// 默认语言，这里的local属性，对应message中的zh、en属性
	locale: uni.getStorageSync('locale')?uni.getStorageSync('locale'):'en',
	// 引入语言文件
	messages: {
		// 这里的属性名是任意的，您也可以把zh设置为cn等，只是后续切换语言时
		// 要标识这里的语言属性，如：this.$i18n.locale = zh|en|zh|xxx
		'zh': zh, // 这里为上面通过import引入的语言包
		'en': en,
		'th':th,//泰文
	}
})
Vue.prototype.navrouter = function(url){
	uni.navigateTo({
		url,
		animationType:'slide-in-right',
		animationDuration:300
	})
}
// Vue.prototype.Themecolor = '#AC1F33' //#5412c6;
Vue.prototype.Themecolor = '#AC1F33' //#5412c6;
// 由于微信小程序的运行机制问题，需声明如下一行，H5和APP非必填
Vue.prototype._i18n = i18n

const app = new Vue({
	i18n,
	store,
	...App
})
import httpInterceptor from '@/common/http.interceptor.js'
Vue.use(httpInterceptor, app)
Vue.prototype.isanimate = function(){
	
	let animat = 'zoomIn'
	let status = Math.floor( Math.random()*6)
	if(status == 0){//动画效果
		//无动画
		animat = ''
	}else if(status == 1){
		//渐渐显示
		animat = 'fadeIn'
	}else if(status == 2){
		//从上往下
		animat = 'fadeInDownBig'
	}else if(status == 3){
		//从下往上
		animat = 'fadeInUpBig'
	}else if(status == 4){
		//横向转动
		animat = 'flipInY'
	}else{
		//放大
		animat = 'zoomIn'
	}
	return animat
}
Vue.prototype.navrouter = function(url){
	uni.navigateTo({
		url
	})
}
Vue.prototype.copy = (content, display = true) => {
	// 复制内容，必须字符串，数字需要转换为字符串
content = typeof content === 'string' ? content : content.toString();
//#ifndef H5
uni.setClipboardData({
	data: content,
	success: function () {
	display ? msg('复制成功') : msg('复制成功');
	},
	fail: function () {
	msg('复制失败');
	},
});
//#endif
// #ifdef H5
if (!document.queryCommandSupported('copy')) {
	//为了兼容有些浏览器 queryCommandSupported 的判断
	msg('浏览器不支持');
}
let textarea = document.createElement('textarea');
textarea.value = content;
textarea.readOnly = 'readOnly';
document.body.appendChild(textarea);
textarea.select(); // 选择对象
textarea.setSelectionRange(0, content.length); //核心
let result = document.execCommand('copy'); // 执行浏览器复制命令
if (result) {
	display ? msg('复制成功') : msg('success');
} else {
	msg('复制失败');
}
textarea.remove();
// #endif
};
Vue.prototype.ossThree = (url) => {
	let image = '';
	if (url) {
		if (url.indexOf('http') == -1) {//不包含
		// console.log(baseUrl)
		// image = 'http://backwang.natapp1.cc'+url;
		image = 'https://doc.seemyshow.cn'+url;
		} else {
		image = url;
		}
		// console.log(image)
	}
	return image;
	};	
const msg = (title, duration = 1500, mask = false, icon = 'none') => {
	//统一提示方便全局修改
	if (Boolean(title) === false) {
		return;
	}
	uni.showToast({ title, duration, mask, icon });
	
	};	
import httpApi from '@/common/http.api.js'
Vue.use(httpApi, app)
Vue.use(Vuex, app);
app.$mount()
